import { includes } from '../share'
import Watcher from './watcher'

export default class Dep {
  subs = []
  append() {
    const watcher = Dep.target
    if (!watcher) return
    if (!includes(this.subs, watcher)) {
      this.subs.push(watcher)
    }
  }
  notify() {
    this.subs.forEach(watcher => {
      watcher.update()
    })
  }
}

Dep.target = null
